<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

/**
 * Class HealthComment
 * @package App
 */
class HealthComment extends Model
{
    public $timestamps=false;
    protected $table='health_comment';

    /**
     * 回复资讯
     * @param $request
     * @return array
     */
    static function Repay($request)
    {
        $time = date('Y-m-d H:i:s');
        $user = User::select('uuid','name','c_avatar')->where('c_id', $request->user_id)->first();
        $repay = new HealthComment();
        $repay->information_id = $request->information_id;
        $repay->comment = $request->contents;
        $repay->user_uuid = $user->uuid;
        $repay->user_name = $user->name;
        $repay->user_head = $user->c_avatar;
        $repay->creat_time = $time;
        $repay->praise = 0;
        $repay->praise_state = 0;
        if (!$repay->save()) {
            return ['status' => 2, 'message' => '回复失败'];
        }
        return ['status' => 1, 'message' => '回复成功', 'data' => ['user_head' => $user->c_avatar, 'user_name' => $user->name, 'creat_time' => $time, 'contents' => $request->contents]];
    }

}
